﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;

using System.Net.Mail;

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {



    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //if (TextBox1.Text.Equals("admin") && TextBox2.Text.Equals("admin"))
        //{
        //    Session["email"] = TextBox1.Text;
        //    Response.Redirect("admin/dashboard.aspx");

        //}
        SqlConnection con = null;

        con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        con.Open();


        SqlCommand cmd1 = new SqlCommand("SELECT * FROM admin1 where username='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'", con);

        SqlDataReader dr2 = cmd1.ExecuteReader();
        //Response.Write(@"<script language='javascript'>alert('loop 1')</script>");

        if (dr2.Read())
        {
            Response.Write(@"<script language='javascript'>alert('inside')</script>");
            if (TextBox1.Text.Equals(dr2[0].ToString()) && TextBox2.Text.Equals(dr2[1].ToString()))
            {
                Session["email"] = TextBox1.Text;
                string email = dr2[2].ToString();




                Response.Redirect("hw/dashboard.aspx");
                con.Close();



            }

        }
        dr2.Close();

        //SqlCommand cmd = new SqlCommand("SELECT * FROM agent_add where email='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'", con);

        //SqlDataReader dr = cmd.ExecuteReader();
        //// Response.Write(@"<script language='javascript'>alert('loop 1')</script>");

        //if (dr.Read())
        //{
        //    // Response.Write(@"<script language='javascript'>alert('inside')</script>");
        //    if (TextBox1.Text.Equals(dr[13].ToString()) && TextBox2.Text.Equals(dr[14].ToString()))
        //    {
        //        Session["email"] = TextBox1.Text;
        //        string type = dr[15].ToString();

        //        if (type == "Super Agent")
        //        {
        //            Session["email"] = TextBox1.Text;
        //            //Response.Redirect("recruiter_verify1.aspx");
        //            Response.Redirect("super_agent/super_agent_dashboard.aspx");
        //            con.Close();
        //        }
        //        else if (type == "Agent")
        //        {
        //            Session["email"] = TextBox1.Text;
        //            //Session["email"] = Label1.Text;
        //            Response.Redirect("agent/dashboard_agent.aspx");
        //            con.Close();
        //        }
        //        else if (type == "Partner")
        //        {
        //            Session["email"] = TextBox1.Text;
        //            Response.Redirect("partner/dahboard_partner.aspx");
        //            con.Close();
        //        }


        //        dr.Close();
        //    }
    }



}







